<?=$header?>
<script src="<?=base_url();?>system/scriptaculous/lib/prototype.js" type="text/javascript"></script>
<script src="<?=base_url();?>system/scriptaculous/src/scriptaculous.js" type="text/javascript"></script>
<script src="<?=base_url();?>system/scriptaculous/src/unittest.js" type="text/javascript"></script>

<p>
<div id="container"></div>
<script language="javascript" type="text/javascript">
function deleteOption(id){
	if(confirm("Are you sure you want to delete this option?")){
		window.location="<?=base_url();?>options/delete/"+id;
	}
}
</script>

<?
$query = $this->db->query('SELECT * FROM gcms_options');
echo form_open('options/edit');
echo '<table border="0" cellpadding="2" cellspacing="0" style="width:100%">';
echo '<thead style="background:#464646;color:#D7D7D7;height:30px;"><th>id</th><th>option name</th><th>option value</th><th>action</th></thead>';
echo'<tbody>';
$i = 0;
foreach ($query->result() as $row)
{
	if($row->option_name != 'theme'){
		if($i == 0) $colour = "#F4F4F4"; 
		else $colour = "#E4E4E4"; 
		
		echo '<tr style="background:'.$colour.'"><td>'.$row->option_id.'</td><td>'.$row->option_name.'</td><td>'.form_input('option'.$row->option_id, $row->option_value).'</td><td>';
		if($row->option_name != "title") echo '<a href="#" onclick="deleteOption('.$row->option_id.');">delete</a></td></tr>';
		else echo '&nbsp;</td></tr>';
		
		$i++;
		if($i > 1) $i = 0;
	}
}
echo '<tr><td colspan="4">'.form_submit('submit', 'Save').'</td></tr>';
echo'</tbody>';
echo'</table>';
echo form_close();
?>
<br />

<div class="option_box">
	<a onclick="Effect.toggle('add_box', 'slide');"><h2>Add an Option</h2></a>
	<div id="add_box" style="display:none;">
		<form id="add-form" method="post" action="options/add">
		<table>
		<tr><td>Option Name</td><td><input type="text" name="option_name" value="" maxlength="500" size="20"  /></td></tr>
		<tr><td>Option Value</td><td><input type="text" name="option_value" value="" maxlength="500" size="20"  /></td></tr>
		<tr><td colspan="2"><input type="submit" id="subbut" value="Add Option" /></td></tr>
		</table>
		</form>
	</div>
</div>
</p>

<?=$footer?>

</body>
</html>